import copy
import weakref


# https://blog.csdn.net/NeverLate_gogogo/article/details/107021695

class C(object):
    val: int = 3

    def __init__(self, value):
        self.value = value


if __name__ == '__main__':
    a = [1, 2, 3]
    b = copy.deepcopy(a)

    # 只比较id()
    print(a is b)
    # 比较值
    print(a == b)

    a_set = {0, 1}
    wref = weakref.ref(a_set)
    print(wref())

    a_set = {2, 3, 4}
    print(wref())

    print(C.val)
    # print(C.value)

    c_obj = C(2)
    ref = weakref.ref(c_obj)
    del c_obj
    # print(ref().value)
    print(ref())

    # 不建议使用proxy
    # c2_obj = C(22)
    # proxy = weakref.proxy(c2_obj)
    # del c2_obj
    # print(proxy.value)

    print('done')
